home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
SSShape.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
7KB
|
204 lines
class SSShape extends SSObject
{
var isInstance = false;
var disabled = false;
var assetID = null;
var depthLayer = 2;
var className = "Shape";
var setShape = Object.prototype.constructor;
var classID = SSGlobal.CLSID_SHAPE;
var editor_name = "Shape";
var editor_isItem = true;
var editor_tool = "CreateShape";
var editor_args_names = ["style"];
var editor_args_values = ["DSGeneric"];
var editor_args_types = ["string"];
var editor_args_options = [["DSGeneric"]];
var editor_args_descriptions = [];
var editor_args_mode = [0];
var editor_args_component = ["List"];
var editor_commands = ["Reverse"];
var editor_canChangeAsset = false;
var editor_canChangeFrame = false;
var editor_canChangeName = false;
var editor_nullDefaultsOnSave = false;
function SSShape(style)
{
super();
if(this.isInstance || arguments.length < 1)
{
return undefined;
}
this.style = !(style != null && typeof style != "string") ? SSDrawStyle : style;
var _loc5_ = arguments.slice(1);
this.points = [];
var _loc4_ = _loc5_.length;
while((_loc4_ = _loc4_ - 1) > -1)
{
this.points.push(new SSShapeVertex(_loc5_[_loc4_ = _loc4_ - 1],_loc5_[_loc4_ = _loc4_ - 1],_loc5_[_loc4_ + 3]));
}
this.points[0].props = _loc5_[2];
this.points.reverse();
this.build();
}
function onAddToWorld()
{
if(this.drawStyle.store)
{
this.world.addToCollection(this.drawStyle.className,this);
}
}
function updateBounds()
{
var _loc2_ = this.leftSector != (this.leftSector = Math.floor((this.left = this.x + this.localLeft) / SSGlobal.GRID_SIZE));
var _loc3_ = this.topSector != (this.topSector = Math.floor((this.top = this.y + this.localTop) / SSGlobal.GRID_SIZE));
var _loc4_ = this.rightSector != (this.rightSector = Math.floor((this.right = this.x + this.localRight) / SSGlobal.GRID_SIZE));
var _loc5_ = this.bottomSector != (this.bottomSector = Math.floor((this.bottom = this.y + this.localBottom) / SSGlobal.GRID_SIZE));
if(_loc2_ || _loc3_ || _loc4_ || _loc5_)
{
this.removeFromSectorGrid();
this.addToSectorGrid();
}
}
function build()
{
var _loc9_ = this.points.length - 1;
var _loc2_ = undefined;
var _loc3_ = undefined;
var _loc4_ = undefined;
var _loc8_ = undefined;
var _loc6_ = undefined;
var _loc7_ = undefined;
var _loc5_ = undefined;
_loc8_ = _loc6_ = this.points[_loc9_].x;
_loc7_ = _loc5_ = this.points[_loc9_].y;
this.colEdges = [];
this.edges = [];
this.edges[_loc9_] = new SSShapeEdge(this.points[_loc9_],this.points[0]);
while((_loc9_ = _loc9_ - 1) > -1)
{
this.edges[_loc9_] = new SSShapeEdge(this.points[_loc9_],this.points[_loc9_ + 1]);
this.points[_loc9_].index = _loc9_;
this.edges[_loc9_].next = this.edges[_loc9_ + 1];
this.edges[_loc9_ + 1].previous = this.edges[_loc9_];
_loc8_ = Math.min(this.points[_loc9_].x,_loc8_);
_loc6_ = Math.max(this.points[_loc9_].x,_loc6_);
_loc7_ = Math.min(this.points[_loc9_].y,_loc7_);
_loc5_ = Math.max(this.points[_loc9_].y,_loc5_);
}
_loc9_ = this.edges.length - 1;
this.edges[_loc9_].next = this.edges[0];
this.edges[0].previous = this.edges[_loc9_];
this.localLeft = _loc8_;
this.localRight = _loc6_;
this.localTop = _loc7_;
this.localBottom = _loc5_;
_loc9_ = this.edges.length;
while((_loc9_ = _loc9_ - 1) > -1)
{
_loc3_ = _loc2_ = this.edges[_loc9_].a;
_loc4_ = _loc2_.b;
_loc2_.shape = this;
_loc2_.center = new Vector(_loc3_.x + (_loc4_.x - _loc3_.x) * 0.5,_loc3_.y + (_loc4_.y - _loc3_.y) * 0.5);
_loc2_.radius = 0.5 * (_loc2_.length = _loc2_.span = new Vector(_loc4_.x - _loc3_.x,_loc4_.y - _loc3_.y).length);
if(_loc3_.x > _loc4_.x)
{
_loc2_.left = _loc4_.x;
_loc2_.right = _loc3_.x;
}
else
{
_loc2_.left = _loc3_.x;
_loc2_.right = _loc4_.x;
}
if(_loc3_.y > _loc4_.y)
{
_loc2_.top = _loc4_.y;
_loc2_.bottom = _loc3_.y;
}
else
{
_loc2_.top = _loc3_.y;
_loc2_.bottom = _loc4_.y;
}
_loc2_.direction = _loc2_.span.getNormalized();
_loc2_.normal = _loc2_.direction.cross();
_loc2_.angle = Math.atan2(_loc2_.direction.y,_loc2_.direction.x) * 180 / 3.141592653589793;
_loc2_.props = _loc3_.props;
if(_loc2_.props & 1)
{
this.colEdges.push(_loc2_);
}
}
_loc9_ = this.edges.length;
while((_loc9_ = _loc9_ - 1) > -1)
{
_loc2_ = this.edges[_loc9_];
(_loc2_.a.normal = new Vector(_loc2_.previous.normal.x + _loc2_.normal.x,_loc2_.previous.normal.y + _loc2_.normal.y)).normalize();
_loc2_.a.scale = 1 / _loc2_.a.normal.dot(_loc2_.normal);
}
(this.drawStyle = new this.style()).init(this.points,this.edges);
if(this.depthLayer != this.drawStyle.depthLayer)
{
this.depthLayer = this.drawStyle.depthLayer;
this.depth = this.calculateDepth();
}
if(this.inScene)
{
this.redraw();
}
}
function redraw()
{
this.removeDisplay();
this.addDisplay();
}
function onAddDisplay()
{
this.target._visible = !this.disabled;
if(this.drawStyle.depthLayer != null)
{
this.depthLayer = Number(this.drawStyle.depthLayer);
this.target.swapDepths(this.calculateDepth());
}
this.drawStyle.draw(this.target);
}
function editor_onInit(obj)
{
this.normals = [];
this.instances = [];
this.points = [];
var _loc4_ = obj.props.slice(obj.propNames.length);
obj.propOptions[10] = _global.__drawStyles;
var _loc3_ = _loc4_.length;
while((_loc3_ = _loc3_ - 1) > -1)
{
this.points.push(new Vector(Number(_loc4_[_loc3_ = _loc3_ - 1]),Number(_loc4_[_loc3_ = _loc3_ - 1]),Number(_loc4_[_loc3_])));
}
}
function editor_onDisplay(target, external)
{
target.drawClip.removeMovieClip();
var _loc4_ = target.createEmptyMovieClip("drawClip",0);
var _loc6_ = SSShape;
var _loc0_ = null;
var _loc5_ = this.shapeObj = {};
_loc5_.__proto__ = _loc6_.prototype;
_loc6_.apply(_loc5_,[_global[this.props[10]]].concat(this.props.slice(11)));
_loc5_.drawStyle.showInfo();
_loc5_.drawStyle.draw(_loc4_);
_loc4_ = target.createEmptyMovieClip("shape",1);
_loc4_.beginFill(13421806,0);
var _loc3_ = this.points.length;
_loc4_.moveTo(this.points[0].x,this.points[0].y);
while((_loc3_ = _loc3_ - 1) > -1)
{
_loc4_.lineTo(this.points[_loc3_].x,this.points[_loc3_].y);
}
_loc4_.endFill();
}
function editor_onSelect()
{
}
}